<?php
/**
 * Laravel-admin - admin builder based on Laravel.
 * @author z-song <https://github.com/z-song>
 *
 * Bootstraper for Admin.
 *
 * Here you can remove builtin form field:
 * Encore\Admin\Form::forget(['map', 'editor']);
 *
 * Or extend custom form field:
 * Encore\Admin\Form::extend('php', PHPEditor::class);
 *
 * Or require js and css assets:
 * Admin::css('/packages/prettydocs/css/styles.css');
 * Admin::js('/packages/prettydocs/js/main.js');
 *
 */

Encore\Admin\Form::forget(['editor']);


//扩展一个switch
use Encore\Admin\Grid\Column;
use App\Admin\Extensions\MySwitchDisplay;

Column::extend('mySwitch', MySwitchDisplay::class);
//explan
Admin::script("$('.grid-expand').on('click', function () {
    if ($(this).data('inserted') == '0') {
        var key = $(this).data('key');
        var row = $(this).closest('tr');
        var html = $('template.grid-expand-'+key).html();

        row.after(\"<tr><td colspan='\"+row.find('td').length+\"' style='padding:0 !important; border:0px;'>\"+html+\"\");

        $(this).data('inserted', 1);
    }

    $(\"i\", this).toggleClass(\"fa-caret-right fa-caret-down\");
});");

//扩展编译器

use Encore\Admin\Form;

use App\Admin\Extensions\Form\KindEditor;

Form::extend('kindeditor', KindEditor::class);

//use App\Admin\Extensions\Form\QiniuKindEditor;
//
//Form::extend('qiniu_kindeditor', QiniuKindEditor::class);

//Grid 扩展
use App\Admin\Extensions\Grid\Popover;
use App\Admin\Extensions\Grid\FancyImage;
use App\Admin\Extensions\Grid\GridExpand;


Column::extend('popover', Popover::class);
Column::extend('fancyImage', FancyImage::class);
Column::extend('gridExpand', GridExpand::class);